package com.alveole.events;

import javax.ejb.Stateful;



import javax.enterprise.context.RequestScoped;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import com.alveole.objects.BrowserSession;
import com.alveole.tools.Logger;

// Bean that receives directly data from a connection
@Stateful
public class EventBean {
	public String command;
	public String data;
	public String target;
	public BrowserSession browserSession;
	
	@PersistenceContext
	private EntityManager entityManager;
	
	public String getResponse()
	{
		Logger.log(Logger.USERRUN, browserSession.getUser().getLogin() + "|"
				 + "command=" + command +"|"
				 + "target=" + target +"|"
				 + "data=" + data +"|"); 
		
	  	
		return Event.EventListAsJSON(BrowserEvent.process(this));

	}

	public String getCommand() {
		return command;
	}

	public void setCommand(String command) {
		this.command = command;
	}

	public String getData() {
		return data;
	}

	public void setData(String data) {
		this.data = data;
	}

	public String getTarget() {
		return target;
	}

	public void setTarget(String target) {
		this.target = target;
	}

	public BrowserSession getBrowserSession() {
		return browserSession;
	}

	public void setBrowserSession(BrowserSession browserSession) {
		this.browserSession = browserSession;
	}

	public EntityManager getEntityManager() {
		return entityManager;
	}

	public void setEntityManager(EntityManager entityManager) {
		this.entityManager = entityManager;
	}

	
	
}
